package exam.business.service;

import java.util.Date;

import exam.common.constant.ResultPort;
import exam.common.key.KeyExamination;
import exam.common.util.NullCheckUtil;
import exam.model.dao.TExaminationDAO;
import exam.model.entity.TExaminationEntity;
import exam.system.business.AbstractService;
import exam.system.business.BusinessServiceInfo;
/**
 * <p>ExaminationUpdateService</p>
 * <br>
 * <p>Xu ly cap nhat thong tin de thi</p>
 * 
 * @author Phong
 * @version (create: 20/5/2012)
 */
public class ExaminationUpdateService extends AbstractService {
	// tExaminationDAO
	private TExaminationDAO tExaminationDAO = new TExaminationDAO();
	@Override
	public String executeService(BusinessServiceInfo serviceInfo)
			throws Exception {
		// lay tExaminationEntity tu serviceInfo
		TExaminationEntity tExaminationEntity = serviceInfo.getObject(KeyExamination.T_EXAMINATION_ENTITY);
		if(NullCheckUtil.isNotNull(tExaminationEntity)) {
			tExaminationEntity.setUpdateDate(new Date());
			// goi phuong thuc cap nhat 
			int update = tExaminationDAO.updateExamination(tExaminationEntity);
			if(update == 0) {
				return ResultPort.FAIL;
			} else {
				return ResultPort.SUCCESS;
			}
		}
		return ResultPort.FAIL;
	}

}
